home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-01 / lcppb.zip / LCPPANS.ZIP / UPPERSTR.CPP < prev    next >
C/C++ Source or Header  |  1991-07-08  |  942b  |  44 lines

  1. // upperstr.cpp -- An uppercase-string class
  2.  
  3. #include <iostream.h>
  4. #include <string.h>
  5. #include <error.h>
  6. #include <item.h>
  7. #include <stritem.h>
  8.  
  9. class upperStr : public strItem {
  10.   public:
  11.     upperStr(const char *s);
  12.     upperStr(const char *s, int maxLen);
  13. };
  14.  
  15. main()
  16. {
  17.   upperStr *usp = new upperStr("An upper class string");
  18.   cout << "String == " << usp->getString();
  19. }
  20.  
  21. upperStr::upperStr(const char *s) : strItem(s)
  22. {
  23.   char *sp = strdup(s);
  24.   if (sp == NULL) error(ERRMEM);
  25.   putString(strupr(sp));
  26.   delete sp;
  27. }
  28.  
  29. upperStr::upperStr(const char *s, int maxLen) : strItem(s, maxLen)
  30. {
  31.   char *sp = strdup(s);
  32.   if (sp == NULL) error(ERRMEM);
  33.   putString(strupr(sp), maxLen);
  34.   delete sp;
  35. }
  36.  
  37.  
  38. // Copyright (c) 1990 by Tom Swan. All rights reserved
  39. // Revision 1.00    Date: 12/05/1990   Time: 05:21 pm
  40.  
  41. // Revision 1.01    Date: 07/08/1991   Time: 05:41 pm
  42. // Converted for Borland C++ 2.0
  43.  
  44.